import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AssetCategoryVO, AssetCategoryForm, AssetCategoryQuery } from '@/api/erp/assetCategory/types';

/**
 * 查询资产分类列表
 * @param query
 * @returns {*}
 */

export const listAssetCategory = (query?: AssetCategoryQuery): AxiosPromise<AssetCategoryVO[]> => {
  return request({
    url: '/erp/assetCategory/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询资产分类详细
 * @param id
 */
export const getAssetCategory = (id: string | number): AxiosPromise<AssetCategoryVO> => {
  return request({
    url: '/erp/assetCategory/' + id,
    method: 'get'
  });
};

/**
 * 新增资产分类
 * @param data
 */
export const addAssetCategory = (data: AssetCategoryForm) => {
  return request({
    url: '/erp/assetCategory',
    method: 'post',
    data: data
  });
};

/**
 * 修改资产分类
 * @param data
 */
export const updateAssetCategory = (data: AssetCategoryForm) => {
  return request({
    url: '/erp/assetCategory',
    method: 'put',
    data: data
  });
};

/**
 * 删除资产分类
 * @param id
 */
export const delAssetCategory = (id: string | number | Array<string | number>) => {
  return request({
    url: '/erp/assetCategory/' + id,
    method: 'delete'
  });
};
